Skip to content

Commit

Permalink
Make RS as regexp work without ifdef. Add doc, bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldrobbins committed Oct 6, 2019
1 parent 643a5a3 commit 7cae39d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
10 changes: 9 additions & 1 deletion ChangeLog
@@ -1,3 +1,11 @@
2019-10-06 Arnold D. Robbins <arnold@skeeve.com>

* lib.c (readrec): Allow RS a regular expression. Imported
the code from the NetBSD awk.
* b.c (fnematch): New function for implementing the feature.
* awk.1: Updated.
* main.c (version): Updated.

2019-06-24 Arnold D. Robbins <arnold@skeeve.com>

* makefile: Revise to take into account there is no more awktest.tar,
Expand All @@ -18,7 +26,7 @@
* b.c (relex): Count parentheses and treat umatched right paren
as a literal character.
* awktest.tar (testdir/T.re): Added a test case.
* main.c (version): Upated.
* main.c (version): Updated.

2019-05-29 Arnold D. Robbins <arnold@skeeve.com>

Expand Down
4 changes: 4 additions & 0 deletions FIXES
Expand Up @@ -25,6 +25,10 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the AWK book
was sent to the printers in August, 1987.

October 6, 2019:
Import code from NetBSD awk that implements RS as a regular
expression.

September 10, 2019:
Fixes for various array / memory overruns found via gcc's
-fsanitize=unknown. Thanks to Alexander Richardson (Github
Expand Down
5 changes: 5 additions & 0 deletions awk.1
Expand Up @@ -478,6 +478,11 @@ the length of a string matched by
.TP
.B RS
input record separator (default newline).
If empty, blank lines separate records.
If more than one character long,
.B RS
is treated as a regular expression, and records are
separated by text matching the expression.
.TP
.B RSTART
the start position of a string matched by
Expand Down
4 changes: 0 additions & 4 deletions lib.c
Expand Up @@ -209,7 +209,6 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf *
int bufsize = *pbufsize;
char *rs = getsval(rsloc);

#ifdef RS_AS_REGEXP
if (*rs && rs[1]) {
int found;

Expand All @@ -218,7 +217,6 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf *
if (found)
*patbeg = 0;
} else {
#endif
if ((sep = *rs) == 0) {
sep = '\n';
while ((c=getc(inf)) == '\n' && c != EOF) /* skip leading \n's */
Expand Down Expand Up @@ -247,9 +245,7 @@ int readrec(char **pbuf, int *pbufsize, FILE *inf) /* read one record into buf *
if (!adjbuf(&buf, &bufsize, 1+rr-buf, recsize, &rr, "readrec 3"))
FATAL("input record `%.30s...' too long", buf);
*rr = 0;
#ifdef RS_AS_REGEXP
}
#endif
*pbuf = buf;
*pbufsize = bufsize;
isrec = *buf || !feof(inf);
Expand Down
2 changes: 1 addition & 1 deletion main.c
Expand Up @@ -22,7 +22,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/

const char *version = "version 20190910";
const char *version = "version 20191006";

#define DEBUG
#include <stdio.h>
Expand Down

0 comments on commit 7cae39d

Please sign in to comment.